using System.Collections.Generic;
using System.IO;
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;
using Rhino.Mocks;
using Pronghorn.Core;

namespace ViewEngine_Tests
{
	[TestFixture]
	public class FileLinkRenderer_Tests
	{
		[Test]
		public void When_a_collection_of_keys_is_passed_generated_a_script_tag_to_the_proper_route_with_the_version()
		{
			var writer = new StringWriter();

			var scripts = new List<string>
			              	{
								"lib-Company.UI.UI",
                                "lib-Company.UI.UI",
								"lib-Company.UI.ListJacket"
			              	};
			var siteContext = new SiteContext
						{
							CssVersion = "V01",
							JsVersion = "V01"
						};
			var renderer = new ScriptRenderer(siteContext);
			renderer.Render(scripts,writer);

			var expected = "<script type=\"text/javascript\" src=\"scripts/js/lib-Company.UI.UI|lib-Company.UI.UI|lib-Company.UI.ListJacket|&version=V01\"></script>\r\n";
			Assert.That(writer.ToString(), Is.EqualTo(expected));
		}

		[Test]
		public void When_a_collection_of_keys_is_passed_generated_a_css_tag_to_the_proper_route_with_the_version()
		{
			var writer = new StringWriter();

			var scripts = new List<string>
			              	{
								"skin-Default",
                                "skin-Default.XXX",
								"widget-Login.Black"
			              	};
			var siteContext = new SiteContext
			{
				CssVersion = "V01",
				JsVersion = "V01"
			};
			var renderer = new CssRenderer(siteContext);
			renderer.Render(scripts, writer);

			var expected = "<link rel=\"stylesheet\" type=\"text/css\" href=\"styles/css/skin-Default|skin-Default.XXX|widget-Login.Black|&version=V01\" />\r\n";
			Assert.That(writer.ToString(), Is.EqualTo(expected));
		}
	}

}